const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const ProductConfig = sequelize.define('ProductConfig', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    stripe_price_id: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true,
        comment: 'Stripe 控制台的 Price ID'
    },
    product_type: {
        type: DataTypes.ENUM('payment', 'subscription'),
        allowNull: false,
        comment: 'payment=一次性购买代币, subscription=订阅会员'
    },
    name: {
        type: DataTypes.STRING,
        allowNull: false,
        comment: '产品名称'
    },
    tokens_amount: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: 'payment=购买的代币数量, subscription=每期发放的代币数量'
    },
    membership_tier: {
        type: DataTypes.INTEGER,
        allowNull: true,
        defaultValue: null,
        comment: '会员等级：1=一级会员，2=二级会员，3=三级会员，null=非会员产品或通用产品'
    },
    is_active: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
        defaultValue: true
    }
}, {
    tableName: 'product_configs',
    comment: '产品配置表'
});

module.exports = ProductConfig;